package com.yuanyi.api.comm.util;

import lombok.Data;
import lombok.extern.log4j.Log4j;

import java.util.LinkedHashMap;
import java.util.Map;

@Log4j
@Data
public class Query extends LinkedHashMap<String, Object> {

    private static final long serialVersionUID = -373014248923423L;

    private int page = 1;

    private int limit = 10;

    public Query(Map<String, Object> params) {
        this.putAll(params);

        if (params.get("page") != null) {
            this.page = Integer.parseInt(params.get("page").toString());
        }

        if (params.get("limit") != null) {
            this.limit = Integer.parseInt(params.get("limit").toString());
        }

        this.remove("page");
        this.remove("limit");
    }

}
